#pragma once

#include "entity.h"
#include "core/listallocator.h"

struct scene_t:entity_t
{
	DECLARE_ENTITY;
	scene_t();

	void init();
	void update();
	void initrecursive();
	void exitrecursive();
	void updaterecursive();
	void generateentitymap();

	entity_t* getentity(const char* entityname);

	struct dyn_struct_t
	{
		entity_t* cloned;
		entity_t* proto;

		dyn_struct_t(){}
		dyn_struct_t(entity_t*c,entity_t*p):cloned(c),proto(p){}
	};

	typedef listallocator_t<dyn_struct_t,1024> dynamic_array_t;
	dynamic_array_t dynamic_entity_array;
	//	vector<dyn_struct_t> dynamic_entity_array;
	vector<dyn_struct_t> to_add;
	//	vector<entity_t*> to_exit;
	entity_ptr_t add_dynamic_entity(entity_t* prototype, const float4x4& pos);
	entity_t* add_dynamic_entity_ptr(entity_t* prototype, const float4x4& pos);
	void update_dynamic_scene();

	hashmap_t<entity_t,16384> entity_map;

	//properties
	float FOV;
	float renderPlaneDist;
};

